fix(fspy): unify shared memory on a sparse temp file across all platforms - #576
Open
wan9chi wants to merge 1 commit into
Open
fix(fspy): unify shared memory on a sparse temp file across all platforms#576wan9chi wants to merge 1 commit into
wan9chi wants to merge 1 commit into
Conversation
Member
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Jul 28, 2026
wan9chi
force-pushed
the
fspy-sparse-file-shm
branch
from
July 28, 2026 11:06
4f029ee to
cfb9f15
Compare
fspy benchmarklinuxmacoswindows |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f029ee6c9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
wan9chi
force-pushed
the
fspy-sparse-file-shm
branch
6 times, most recently
from
July 30, 2026 02:14
5e527ad to
f572f0d
Compare
wan9chi
force-pushed
the
fspy-sparse-file-shm
branch
from
July 30, 2026 03:24
f572f0d to
ca1932a
Compare
wan9chi
commented
Jul 30, 2026
wan9chi
force-pushed
the
fspy-sparse-file-shm
branch
3 times, most recently
from
July 30, 2026 03:51
54dbb9b to
126f02b
Compare
…orms Codex CLI's and Claude Code's default sandboxes deny the primitives fspy's Unix shared memory was built on: the macOS Seatbelt profile denies `shm_open` (`ipc-posix-shm-write-create`), and both sandboxes block Unix-domain sockets, which the Linux memfd broker depended on. Plain files in the temp directory are writable under both. Replace all three backends with one file-backed implementation attached by path: a sparse temporary file plus `memmap2`, with the file's absolute path as the identifier. No broker, no tokio requirement, no global object names. Lifetime semantics converge too: dropping the owner makes the name disappear and later opens fail, while existing views stay usable — now on Windows as well, where closing the delete-on-close handle applies the delete disposition even while other processes hold views. Refs #563. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
wan9chi
force-pushed
the
fspy-sparse-file-shm
branch
from
July 30, 2026 04:11
126f02b to
c86913c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation
Codex CLI's and Claude Code's default sandboxes deny the primitives fspy's Unix shared memory was built on. The macOS Seatbelt profile denies
shm_open(#563), and both sandboxes block Unix domain sockets, which the Linux memfd broker depended on. Plain files in the temp directory work under both sandboxes; the IPC lock file lives there today.This PR replaces all three platform backends with one file-backed implementation, mapped through
memmap2on every platform. The API has three types, each one platform concept:ShmKeeperis the name.createreturns it, it carries the identifier (the backing file's absolute path), and dropping it removes the file withremove_file.ShmHandleis the opened file.createreturns one, so the creator never looks its own file up by name, andopenreturns one to everybody else.mapcan be called more than once.Mappingis the bytes. It keeps them alive until dropped and cannot affect the name.Removal works on every platform because modern Windows deletes with POSIX semantics: the name goes away at once, existing handles keep working, and mapped views keep the data alive. CI probes on Windows Server confirmed both, with a live writable view and with an open share-delete handle. The docs reserve the right to fail the delete while a view is mapped, and Windows versions without POSIX delete do fail it, so the keeper falls back to reopening the file with
FILE_FLAG_DELETE_ON_CLOSEand closing it. Unit tests pin the full removal semantics: name gone with a live mapping, name gone with an open handle, and the handle still mapping the same bytes afterwards.Name removal is cleanup. The channel invalidates contents inside the shared bytes, so nothing depends on removal timing. Backing files sit directly in the system temp directory as
vite-task-fspy-<uuid>.shmwith mode0o600; a shared subdirectory would belong to whichever user created it first and lock everyone else out. The identifier is resolved to an absolute path at creation, so a relativeTMPDIRin the creating process cannot mislead an opener with a different working directory.There is no broker, no global object name, no tokio requirement, and no hand-written mapping code: the Windows-specific parts shrink to the sparse-file
FSCTLand the creation flags.If the keeper's process is killed, the file stays behind: on Unix for the temp reaper, on Windows until a cleanup tool runs. It costs about as much disk as the run wrote into it.
Refs #563.
🤖 Generated with Claude Code